package dongze.com.ckdj.activity;

import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.text.TextUtils;
import android.util.Log;
import android.widget.FrameLayout;

import org.greenrobot.eventbus.EventBus;

import dongze.com.ckdj.R;
import dongze.com.ckdj.event.RefreshEvent;
import dongze.com.ckdj.fragment.CheckInOperationFragment;
import dongze.com.ckdj.fragment.CheckInOperationRecordFragment;
import dongze.com.ckdj.util.MyLog;

/**
 * Created by fanqwz on 2017/8/13.
 */

public class InspectionActivity extends BaseActivity {
    private static final String TAG = InspectionActivity.class.getSimpleName();

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        MyLog.d(TAG, "onCreate: " + this);
        setContentView(R.layout.activity_inspection);

        if (TextUtils.isEmpty(getIntent().getStringExtra("id"))) {
            getSupportFragmentManager()
                    .beginTransaction()
                    .add(R.id.fragment_container, new CheckInOperationFragment())
                    .commitAllowingStateLoss();
        } else {
            CheckInOperationRecordFragment checkInOperationRecordFragment = new CheckInOperationRecordFragment();
            checkInOperationRecordFragment.setID(getIntent().getStringExtra("id"));
            getSupportFragmentManager()
                    .beginTransaction()
                    .add(R.id.fragment_container, checkInOperationRecordFragment)
                    .commitAllowingStateLoss();
        }
    }

    @Override
    protected void onDestroy() {
        super.onDestroy();
        EventBus.getDefault().post(new RefreshEvent(true));
    }
}
